// Copyright 2022 jeff.li. and/or its affiliates.

#include <gtest/gtest.h>
#include <tbir/runtime/container.h>

namespace tbir::runtime {

    TEST(Tuple, len) {
        auto tup = Tuple::dynamic(1, 2.5f, "a", List({1, 2}));
        ASSERT_EQ(tup.size(), 4);
    }

    TEST(Tuple, iterator) {
        auto tup = Tuple::dynamic(1, 2.5f, "a", List({1, 2}));
        for (auto &item : tup) {
            std::cout << item << std::endl;
        }
    }

    TEST(Tuple, hash) {
        auto tup = Tuple::dynamic(1, "a");
        auto hash = std::hash<RTValue>()(tup);
        std::cout << hash << std::endl;
    }

    TEST(Tuple, equal) {
        auto tup1 = Tuple::dynamic(1, "a", List({1, 2}));
        auto tup2 = Tuple::dynamic(1, "a", List({1, 2}));
        EXPECT_EQ(tup1, tup2);
    }

    TEST(Tuple, AsDictKey) {
        Dict t;
        auto tup1 = Tuple::dynamic(1, "a");
        auto tup2 = Tuple::dynamic(1, "a");
        t[tup1] = 1;
        EXPECT_TRUE(t.contains(RTView(tup2)));
    }

}  // namespace tbir::runtime
